﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Implicit Grant - Client Page</title>
</head>
<body style="background-color: azure">
    <h1>Implicit Grant</h1>
    <h2>Client Page</h2>
    <form id="form1">
        <div>
            <div id="state"></div>
            <br />
            <input id="Authorize" type="button" name="signin.AccessToken" value="登录" />
            <input id="SignOut" type="button" value="注销" />
            <input id="CallApi" name="submit.CallApi" value="调用API" type="button" />
        </div>
        <div id="output">
        </div>
    </form>

    <script src="../Scripts/jquery-1.10.2.js"></script>
    <script src="../Scripts/jquery.cookie.js"></script>
    <script src="../Scripts/oauth-bearer.js"></script>

    <script type="text/javascript">

        $(function () {

            $.post(apiHost + getNickNameUrl, {}, function (data) {
                if (data.IsLogin == true) {
                    $('#state').text('欢迎您，'+data.NickName);
                } else {
                    $('#state').text('未登录');
                }
            });


            $('#Authorize').click(goToSignIn);

            $('#SignOut').click(function () {
                oauthBearerSignOut();
            });

            $('#CallApi').click(function () {
                $('#output').text('');

                //ajax test
                //$.ajax(apiUrl, {
                //    method: 'post',
                //    cache: false,
                //    success: function (data) {
                //        console.log(data);
                //        $('#output').text(data);
                //    }
                //});

                //post test
                //$.post(apiUrl, {}, function (data) {
                //    $('#output').text(data);
                //});

                //get test
                $.get(apiUrl, {}, function (data) {
                    $('#output').text(data);
                });
            });
        });

    </script>


</body>
</html>